/*
 * @lc app=leetcode.cn id=1941 lang=javascript
 *
 * [1941] 检查是否所有字符出现次数相同
 */

// @lc code=start
/**
 * @param {string} s
 * @return {boolean}
 */
var areOccurrencesEqual = function(s) {
  let map = {};
  s.split('').forEach(ch=>{
    map[ch] = map[ch] ? map[ch] + 1 : 1;
  })
  let num;
  for(let key in map) {
    if(num === undefined) {
      num = map[key];
    }else if(num !== map[key]) {
      return false;
    }
  }
  return true;
};
// @lc code=end

